Executing python scripts using dxl

Hello,

Is it possible to execute python scripts from within dxl scripts? If so, how?

-Neeraja.
SystemAdmin - Mon Oct 22 00:49:50 EDT 2012

Re: Executing python scripts using dxl
Mathias Mamsch - Mon Oct 22 10:36:54 EDT 2012

did you try:
 

system("python.exe myscript.py")

 

? Maybe this helps, regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

 

Re: Executing python scripts using dxl
DarshanAC - Thu Oct 13 11:43:08 EDT 2016

Hello Mathias,

 Can I pass dxl string in this system() command..?

Thanks,

Darshan

Re: Executing python scripts using dxl
Mathias Mamsch - Fri Oct 14 03:10:05 EDT 2016

DarshanAC - Thu Oct 13 11:43:08 EDT 2016

Hello Mathias,

 Can I pass dxl string in this system() command..?

Thanks,

Darshan

Yes. Did you try?

Re: Executing python scripts using dxl
DarshanAC - Fri Oct 14 03:35:01 EDT 2016

Mathias Mamsch - Fri Oct 14 03:10:05 EDT 2016

Yes. Did you try?

Yes I tried passing string in system() command, but it is not working. Actually I need to make python code dynamic based on the dxl string value.
 

below is the command I am using in dxl to cal python file.

system("C:\\ismPython\\V3_2\\python.exe C:\\Users\\CDH4ABT\\Desktop\\Data\\CLAuDIA\\out\\Intermediate_File.py")

 

I have a string named 'abc', I need to pass this string via above system() command, because code in python is dependent on sting value.

below is the command where I pass string 'abc'. but its not working.

system("C:\\ismPython\\V3_2\\python.exe C:\\Users\\CDH4ABT\\Desktop\\Data\\CLAuDIA\\out\\Intermediate_File.py abc")

 

Regards,

Darshan

Re: Executing python scripts using dxl
Mathias Mamsch - Fri Oct 14 06:36:46 EDT 2016

DarshanAC - Fri Oct 14 03:35:01 EDT 2016

Yes I tried passing string in system() command, but it is not working. Actually I need to make python code dynamic based on the dxl string value.
 

below is the command I am using in dxl to cal python file.

system("C:\\ismPython\\V3_2\\python.exe C:\\Users\\CDH4ABT\\Desktop\\Data\\CLAuDIA\\out\\Intermediate_File.py")

 

I have a string named 'abc', I need to pass this string via above system() command, because code in python is dependent on sting value.

below is the command where I pass string 'abc'. but its not working.

system("C:\\ismPython\\V3_2\\python.exe C:\\Users\\CDH4ABT\\Desktop\\Data\\CLAuDIA\\out\\Intermediate_File.py abc")

 

Regards,

Darshan

If you have a variable named "abc", then you need to append it to the string, otherwise you will only pass the literal "abc" ... I would have thought that might be obvious! e.g. 

string myQuote (string s) {
    return s; // you should quote your strings before you pass them over the commandline!
    // You need to implement this function, if you need it.
}

string abc = "Hallo"; 
system("C:\\ismPython\\V3_2\\python.exe C:\\Users\\CDH4ABT\\Desktop\\Data\\CLAuDIA\\out\\Intermediate_File.py " (myQuote abc))

Hope this helps, regards, Mathias

Re: Executing python scripts using dxl
DarshanAC - Fri Oct 14 06:42:23 EDT 2016

Mathias Mamsch - Fri Oct 14 06:36:46 EDT 2016

If you have a variable named "abc", then you need to append it to the string, otherwise you will only pass the literal "abc" ... I would have thought that might be obvious! e.g. 

string myQuote (string s) {
    return s; // you should quote your strings before you pass them over the commandline!
    // You need to implement this function, if you need it.
}

string abc = "Hallo"; 
system("C:\\ismPython\\V3_2\\python.exe C:\\Users\\CDH4ABT\\Desktop\\Data\\CLAuDIA\\out\\Intermediate_File.py " (myQuote abc))

Hope this helps, regards, Mathias

Thank you very much Mathias.

Is there any possibility that I can get the result of python file, so that I can use that result in dxl script. ?

Re: Executing python scripts using dxl
Mathias Mamsch - Fri Oct 14 07:01:39 EDT 2016

DarshanAC - Fri Oct 14 06:42:23 EDT 2016

Thank you very much Mathias.

Is there any possibility that I can get the result of python file, so that I can use that result in dxl script. ?

You shoud pass in the name of a temporary file to which the python script stores its output. Then you read the file from DXL after the python finishes. Regards, Mathias

Re: Executing python scripts using dxl
Mathias Mamsch - Fri Oct 14 07:03:46 EDT 2016

Mathias Mamsch - Fri Oct 14 07:01:39 EDT 2016

You shoud pass in the name of a temporary file to which the python script stores its output. Then you read the file from DXL after the python finishes. Regards, Mathias

By the way, there is a "shell" class inside the DXLParallels tutorial, which you can use: 

https://github.com/domoran/DXLParallels/tree/master/lib/core

It will allow you to read the output of a process, get its exit code, etc. Examples are inside the file. Regards, Mathias

Re: Executing python scripts using dxl
DarshanAC - Fri Oct 14 10:49:02 EDT 2016

Hi Mathias,

 

Thank you very much for your valuable response.